package com.ruoyi.productstores.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.productstores.domain.Productstores;
import com.ruoyi.productstores.service.IProductstoresService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品商店关联Controller
 * 
 * @author ruoyi
 * @date 2024-06-30
 */
@RestController
@RequestMapping("/productstores/productstores")
public class ProductstoresController extends BaseController
{
    @Autowired
    private IProductstoresService productstoresService;

    /**
     * 查询商品商店关联列表
     */
    @PreAuthorize("@ss.hasPermi('productstores:productstores:list')")
    @GetMapping("/list")
    public TableDataInfo list(Productstores productstores)
    {
        startPage();
        List<Productstores> list = productstoresService.selectProductstoresList(productstores);
        return getDataTable(list);
    }

    /**
     * 导出商品商店关联列表
     */
    @PreAuthorize("@ss.hasPermi('productstores:productstores:export')")
    @Log(title = "商品商店关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Productstores productstores)
    {
        List<Productstores> list = productstoresService.selectProductstoresList(productstores);
        ExcelUtil<Productstores> util = new ExcelUtil<Productstores>(Productstores.class);
        util.exportExcel(response, list, "商品商店关联数据");
    }

    /**
     * 获取商品商店关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('productstores:productstores:query')")
    @GetMapping(value = "/{productstoreId}")
    public AjaxResult getInfo(@PathVariable("productstoreId") Long productstoreId)
    {
        return success(productstoresService.selectProductstoresByProductstoreId(productstoreId));
    }

    /**
     * 新增商品商店关联
     */
    @PreAuthorize("@ss.hasPermi('productstores:productstores:add')")
    @Log(title = "商品商店关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Productstores productstores)
    {
        return toAjax(productstoresService.insertProductstores(productstores));
    }

    /**
     * 修改商品商店关联
     */
    @PreAuthorize("@ss.hasPermi('productstores:productstores:edit')")
    @Log(title = "商品商店关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Productstores productstores)
    {
        return toAjax(productstoresService.updateProductstores(productstores));
    }

    /**
     * 删除商品商店关联
     */
    @PreAuthorize("@ss.hasPermi('productstores:productstores:remove')")
    @Log(title = "商品商店关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productstoreIds}")
    public AjaxResult remove(@PathVariable Long[] productstoreIds)
    {
        return toAjax(productstoresService.deleteProductstoresByProductstoreIds(productstoreIds));
    }
}
